const { updateserve } = require('../service/user')
module.exports = {
    async updateimg(ctx, next) {
        const imgpath = '/img/' + ctx.request.files.userimg.newFilename
        console.log(imgpath)
        const { id } = ctx.request.body
        const rudata = await updateserve(id, { img: imgpath })
        if (rudata) {
            return ctx.body = {
                code: 200,
                msg: '修改成功',
                imgpath
            }
        }
        return ctx.body = {
            code: 400,
            msg: '修改失败',
        }
    }

    , async updataname(ctx, next) {
        const { id, name } = ctx.request.body
        console.log(id, name)
        const rudata = await updateserve(id, { name: name })
        if (rudata) {
            return ctx.body = {
                code: 200,
                msg: '修改成功',
                name
            }

        }
        return ctx.body = {
            code: 400,
            msg: '修改失败',
        }
    }

}